package com.mobisys.live.service;


import com.mobisys.live.dao.mapper.VideoMapper;
import com.mobisys.live.dao.model.Video;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class VideoService {
    @Autowired
    private VideoMapper videoMapper;

    public int deleteByPrimaryKey(String id){
        return videoMapper.deleteByPrimaryKey(id);
    }

    public int insert(Video record){
        return videoMapper.insert(record);
    }
    public int insertSelective(Video record){
        return videoMapper.insertSelective(record);
    }

    public Video selectByPrimaryKey(String id){
        return  videoMapper.selectByPrimaryKey(id);
    }

    public int updateByPrimaryKeySelective(Video record){
        return  videoMapper.updateByPrimaryKeySelective(record);
    }

    public int updateByPrimaryKey(Video record){
        return  videoMapper.updateByPrimaryKey(record);
    }

    //获取某个频道下的所有视频
    public List<Video> selectByChannelId(String channelId){
        return  videoMapper.selectByChannelId(channelId);
    }

    //获取某个用户的所有视频
    List<Video> selectByUserId(String userId){
        return  videoMapper.selectByUserId(userId);
    }
    //按类别分页查询
    public List<Video> findAll(int currPage, int pageSize,String type) {
       int currIndex = (currPage-1)*pageSize;
        return videoMapper.findAll(currIndex ,pageSize,type);
    }
}
